package com.ss.tmall.service.impl;

import com.ss.tmall.mapper.PropertyMapper;
import com.ss.tmall.pojo.Property;
import com.ss.tmall.pojo.PropertyExample;
import com.ss.tmall.service.PropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @Author: ShengShuai
 * @Description:
 * @Date: Created in 下午 20:28  2017/12/23 0023
 * @Modified By:
 */
@Service
public class PropertyServiceImpl implements PropertyService {
    @Autowired
    PropertyMapper propertyMapper;
    @Override
    public  void  add(Property property){
        propertyMapper.insert(property);
    }
    @Override
    public  void  delete(int id){
        propertyMapper.deleteByPrimaryKey(id);
    }
    @Override
    public  void  update(Property property){
        propertyMapper.updateByPrimaryKeySelective(property);
    }
    @Override
    public  Property get(int id){
      return   propertyMapper.selectByPrimaryKey(id);
    }
    @Override
    public List list(int cid){
        PropertyExample propertyExample=new PropertyExample();
        propertyExample.createCriteria().andCidEqualTo(cid);
        propertyExample.setOrderByClause("id desc");
        return  propertyMapper.selectByExample(propertyExample);
    }

}
